package com.lmk.order.rocket.impl;

import com.lmk.order.service.IOrderPetAcquisitionService;
import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RocketMQMessageListener(
        topic = "order-topic",
        selectorExpression="order-tags",
        consumerGroup = "queue_group_test")
public class RocketMQMsgListener implements RocketMQListener<MessageExt> {
    @Autowired
    private IOrderPetAcquisitionService iOrderPetAcquisitionService;
    @Override
    public void onMessage(MessageExt messageExt) {
        byte[] body = messageExt.getBody();
        String msg = new String(body, CharsetUtil.UTF_8);
        iOrderPetAcquisitionService.remove(Long.valueOf(msg));
        log.info("==）=======》"+msg);

    }
}
